package com.wunong.smart.commission.domain.state;

import com.wunong.smart.commission.application.context.CommissionContext;
import com.wunong.smart.commission.application.request.BaseCommissionRequest;
import com.wunong.smart.commission.client.enums.CommissionOperationEnum;
import com.wunong.smart.commission.domain.model.CommissionDomain;
import com.wunong.smart.commission.domain.state.operation.CommissionOperationFactory;

/**
 * @author create by zealot.zt
 */
public abstract class AbstractCommissionState implements CommissionState {

    @SuppressWarnings("unchecked")
    @Override
    public Object operate(CommissionOperationEnum operationEnum, BaseCommissionRequest request, CommissionDomain domain) {
        // 构建新的请求对象
        CommissionContext<BaseCommissionRequest> context = CommissionContext.of(request, domain);

        // 执行对应的操作
        return CommissionOperationFactory.getOperation(operationEnum).operate(context);
    }

}
